import { Form, Radio, Checkbox, Button } from 'antd';
import { useState } from 'react';
import '../index.css';

function AbsentSetting(props) {
    const [radio1, setRadio1] = useState()
    const [radio2, setRadio2] = useState()
    const [checkGroupValue, setCheckGroupValue] = useState()
    const [checkbox, setCheckbox] = useState()
    const [form] = Form.useForm()

    const onChange1 = (e) => {
        console.log(e.target.value)
        setRadio1(e.target.value)
    }
    const onChange2 = (e) => {
        console.log(e.target.value)
        setRadio2(e.target.value)
    }
    const checkGroupChange = (checkedValues) => {
        console.log(checkedValues)
        setCheckGroupValue(checkedValues)
    }
    const checkChange = (e) => {
        console.log(e.target.checked)
        setCheckbox(e.target.value)
    }
    const handleSubmit = () => {
        console.log(form.getFieldsValue())
        
    }

    return (
        <>
            <div className='index_content'>
                <Form
                    name="settings"
                    form={form}
                >
                    <h3>学生请假设置</h3>
                    <Form.Item label="家长代请假审批人" name="parent">
                        <Radio.Group value={radio1} onChange={onChange1}>
                            <Radio value={1}>仅班主任</Radio>
                            <Radio value={2}>默认选择班主任，可选择其他老师</Radio>
                        </Radio.Group>
                    </Form.Item>
                    <Form.Item label="学生发起请假审批人" name="applicant">
                        <Radio.Group value={radio2} onChange={onChange2}>
                            <Radio value={1}>仅班主任</Radio>
                            <Radio value={2}>默认选择班主任，可选择其他老师</Radio>
                        </Radio.Group>
                    </Form.Item>
                    <Form.Item label="审批通过通知" name="notice">
                        <Checkbox.Group onChange={checkGroupChange} >
                            <Checkbox value={1}>班主任</Checkbox>
                            <Checkbox value={2}>任课老师</Checkbox>
                            <Checkbox value={3}>行政主任</Checkbox>
                        </Checkbox.Group>
                    </Form.Item>
                    <Form.Item label="请假需家长确认" name="determine" >
                        <Checkbox onChange={checkChange} >开启</Checkbox>
                        <br />
                        <p>勾选开启后,学生本人请假、老师代请假都需要经过家长确认</p>
                    </Form.Item>
                    <Button type='primary' onClick={handleSubmit}>保存</Button>
                </Form>
            </div>
        </>
    );


}

export default AbsentSetting;